<template>
	<view>
		<uni-list-item title="头像">
			<view slot="right" class="flex align-center" @click="changeUserPic">
				<image  :src="userpic"
				 style="width: 100rpx;height: 100rpx;"
				 class="rounded-circle"
				></image>
				<text class="iconfont icon-bianji1 ml-2" ></text>
			</view>
		</uni-list-item>
		
		<uni-list-item title="昵称" >
			<view slot="right" class="flex align-center">
				<input class="uni-input text-right" v-model="username"/>
				<text class="iconfont icon-bianji1 ml-2" ></text>
			</view>
		</uni-list-item>
		<picker mode="date" :value="birthday"  @change="onDateChange">
			<uni-list-item title="生日">
				<view slot="right" class="flex align-center">
					<text>{{birthday}}</text>
					<text class="iconfont icon-bianji1 ml-2" ></text>
				</view>
			</uni-list-item>
		</picker>
		<uni-list-item title="性别" @click="changeSex">
			<view slot="right" class="flex align-center">
				<text>{{sexText}}</text>
				<text class="iconfont icon-bianji1 ml-2" ></text>
			</view>
		</uni-list-item>
		<uni-list-item title="情感">
			<view slot="right" class="flex align-center">
				<text>未婚</text>
				<text class="iconfont icon-bianji1 ml-2" ></text>
			</view>
		</uni-list-item>
		<uni-list-item title="家乡">
			<view slot="right" class="flex align-center">
				<text>广东广州</text>
				<text class="iconfont icon-bianji1 ml-2" ></text>
			</view>
		</uni-list-item>
		
		<view class="py-2 px-3">
			<button class="bg-main text-white" style="border-radius: 50rpx; border: 0;" type="primary">
				完成
			</button>
		</view>
	</view>
</template>

<script>
	import uniListItem from "@/components/uni-ui/uni-list-item/uni-list-item.vue"
	const sexArray=['保密','男','女']
	export default {
		components:{
			uniListItem
		},
		data() {
			return {
				userpic:"/static/default.jpg",
				username:"昵称",
				sex:0,
				birthday:"1998-03-27"
			}
		},
		computed:{
			sexText(){
				return sexArray[this.sex]
			}
		},
		methods: {
			// 修改生日
			onDateChange(e){
				console.log(e)
				this.birthday = e.detail.value
			},
			// 修改头像
			changeUserPic(){
				uni.chooseImage({
					count:1,
					sizeType:["compressed"],
					sourceType:["album","camera"],
					success(res) {
						this.userpic = res.tempFilePaths[0];
						console.log(this.userpic,"hhhhh",res)
					}
				})
			},
			// 修改性别
			changeSex(){
				uni.showActionSheet({
					itemList:sexArray,
					success(res) {
						this.sex = res.tapIndex
					}
					
				})
			},
			// 修改情感
			changeEmotion(){
				
			}
		}
	}
</script>

<style>

</style>
